﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CIT.WMS.RM.Bll;
using CIT.WMS.Product.Bll;

namespace CIT.WMS.Other
{
    public partial class FrmKuweiIvt : Form
    {
        public FrmKuweiIvt()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 初始化画面
        /// </summary>
        private void InitFrm()
        {
        }

        private void txtLocation_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
            {
                lblLocation.Text = txtLocation.Text;
                SetData();
                txtLocation.Text = "";
            }
        }

        private void SetData()
        {
            var sql = string.Format("SELECT LTRIM(PartNumber) as PartNumber,Qty FROM wms_T_Inventory WHERE Location_SN='{0}';", this.txtLocation.Text);
            var dt = Utils.NMS.GetDataTable(sql);
            this.dtIvt.DataSource = dt;
        }

        private void FrmKuweiIvt_Load(object sender, EventArgs e)
        {
            InitIvt();
        }

        private void InitIvt()
        {
            DataGridTableStyle dts = new DataGridTableStyle();
            dts.MappingName = "Result";

            this.dtIvt.TableStyles.Add(dts);
            this.dtIvt.TableStyles[0].GridColumnStyles.Clear();

            DataGridTextBoxColumn colPt = new DataGridTextBoxColumn();
            colPt.Width = 120;
            colPt.HeaderText = "料号";
            colPt.MappingName = "PartNumber";
            this.dtIvt.TableStyles[0].GridColumnStyles.Add(colPt);

            DataGridTextBoxColumn colQty = new DataGridTextBoxColumn();
            colQty.Width = 76;
            colQty.HeaderText = "数量";
            colQty.MappingName = "Qty";
            this.dtIvt.TableStyles[0].GridColumnStyles.Add(colQty);
        }
    }
}